<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<meta name="referrer" content="same-origin">
<meta name="referrer" content="no-referrer" />








<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Docker," />










<meta name="description" content="概述&amp;emsp;&amp;emsp;在使用Dockerfile制作一个Docker镜像的时候，通常会使用FROM引入一个基础镜像，在拥抱Docker（二）Dockerfile制作镜像中也说过，”Dockerfile的每一条指令都是对镜像做出一次修改，每次修改都会提交一个新的镜像层“。为了了解镜像究竟是如何分层的，我们需要进一部了解Docker内部的文件存储系统。">
<meta name="keywords" content="Docker">
<meta property="og:type" content="article">
<meta property="og:title" content="拥抱Docker（五）基础原理之存储驱动">
<meta property="og:url" content="http://yoursite.com/2019/08/18/拥抱Docker（五）基础原理之存储驱动/index.html">
<meta property="og:site_name" content="矩阵编程">
<meta property="og:description" content="概述&amp;emsp;&amp;emsp;在使用Dockerfile制作一个Docker镜像的时候，通常会使用FROM引入一个基础镜像，在拥抱Docker（二）Dockerfile制作镜像中也说过，”Dockerfile的每一条指令都是对镜像做出一次修改，每次修改都会提交一个新的镜像层“。为了了解镜像究竟是如何分层的，我们需要进一部了解Docker内部的文件存储系统。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1g62faram38j216c0aydiq.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1g62g398k2uj20i109nt99.jpg">
<meta property="og:updated_time" content="2019-10-24T16:22:00.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="拥抱Docker（五）基础原理之存储驱动">
<meta name="twitter:description" content="概述&amp;emsp;&amp;emsp;在使用Dockerfile制作一个Docker镜像的时候，通常会使用FROM引入一个基础镜像，在拥抱Docker（二）Dockerfile制作镜像中也说过，”Dockerfile的每一条指令都是对镜像做出一次修改，每次修改都会提交一个新的镜像层“。为了了解镜像究竟是如何分层的，我们需要进一部了解Docker内部的文件存储系统。">
<meta name="twitter:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1g62faram38j216c0aydiq.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/08/18/拥抱Docker（五）基础原理之存储驱动/"/>





  <title>拥抱Docker（五）基础原理之存储驱动 | 矩阵编程</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?7d29e6fba8e07d1a8af2414a20e5f2a6";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">矩阵编程</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-主页">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-主页"></i> <br />
            
            主页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-分类"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-所有文章">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-文章"></i> <br />
            
            所有文章
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/18/拥抱Docker（五）基础原理之存储驱动/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="matrix">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="矩阵编程">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">拥抱Docker（五）基础原理之存储驱动</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-18T12:00:56+08:00">
                2019-08-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Docker/" itemprop="url" rel="index">
                    <span itemprop="name">Docker</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2019/08/18/拥抱Docker（五）基础原理之存储驱动/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2019/08/18/拥抱Docker（五）基础原理之存储驱动/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h4><p>&emsp;&emsp;在使用Dockerfile制作一个Docker镜像的时候，通常会使用<strong>FROM</strong>引入一个基础镜像，在<a href="/2019/06/04/拥抱Docker（二）Dockerfile制作镜像/">拥抱Docker（二）Dockerfile制作镜像</a>中也说过，”Dockerfile的每一条指令都是对镜像做出一次修改，每次修改都会提交一个新的镜像层“。为了了解镜像究竟是如何分层的，我们需要进一部了解Docker内部的文件存储系统。<br><a id="more"></a></p>
<h4 id="AUFS"><a href="#AUFS" class="headerlink" title="AUFS"></a>AUFS</h4><p>&emsp;&emsp;Docker最开始采用AUFS作为文件存储驱动，AUFS全称Advanced Multi-Layered Unification Filesystem。在介绍AUFS之前，先说说它的前身UnionFS，一种联合文件挂载系统，通俗地讲就是把多个不同物理位置的目录合并挂载到同一个目录上。UnionFS用到了一个重要的资源管理技术，写时复制（copy on write简称CoW），这种技术能够对可修改资源实现高效的复制，如果一个资源是重复的，且在没有任何修改的情况下，并不需要立即创建一个新的资源，而是共享旧资源的实例。AUFS继承UnionFS的思想，并完全重写了UnionFS，在提高了可靠性和性能的同时，也引入了一些新的概念，比如可写分支平衡。</p>
<h5 id="AUFS示例"><a href="#AUFS示例" class="headerlink" title="AUFS示例"></a>AUFS示例</h5><p>&emsp;&emsp;以AUFS为例，为了更深入地了解AUFS或者是其他类似文件存储系统的特性，特别是写时复制的技术，我着手在Linux上写了一个示例，毕竟实践出真知。首先看一下你的Linux系统是否支持AUFS：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos aufs-demo]<span class="comment"># grep aufs /proc/filesystems</span></span><br><span class="line">nodev   aufs</span><br></pre></td></tr></table></figure></p>
<p>如果看到以上输出，那就可以愉快地进行下面的示例了（我的centos就不支持，需要打补丁）。先创建三个任意的文件夹，并往其中的两个文件夹中分别创建两个文件用于写入内容，比如我创建的一个目录结构：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos aufs-demo]<span class="comment"># tree -a</span></span><br><span class="line">.</span><br><span class="line">├── apple</span><br><span class="line">│   └── apple.txt</span><br><span class="line">├── google</span><br><span class="line">│   └── google.txt</span><br><span class="line">└── mnt</span><br><span class="line"></span><br><span class="line">3 directories, 2 files</span><br></pre></td></tr></table></figure></p>
<p>接着尝试将创建的apple和google（带文件的两个目录）union mount到mnt目录中：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos aufs-demo]<span class="comment"># sudo mount -t aufs -o dirs=./apple:./google none ./mnt</span></span><br><span class="line">[root@VM_0_12_centos aufs-demo]<span class="comment"># tree mnt</span></span><br><span class="line">mnt</span><br><span class="line">├── apple.txt</span><br><span class="line">└── google.txt</span><br></pre></td></tr></table></figure></p>
<p>可以在mnt目录下看到之前apple和google目录下创建的文件了。进入mnt目录，并尝试往mnt目录下的apple.txt写入一行文字：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos aufs-demo]<span class="comment"># cd mnt</span></span><br><span class="line">[root@VM_0_12_centos mnt]<span class="comment"># vi apple.txt </span></span><br><span class="line">this is apple</span><br></pre></td></tr></table></figure></p>
<p>切换到apple目录，查看apple.txt文件：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos apple]<span class="comment"># vi apple.txt </span></span><br><span class="line">this is apple</span><br></pre></td></tr></table></figure></p>
<p>可以看到之前在/mnt/apple.txt中写入的文字，现在出现在/apple/apple.txt中。不过奇怪的是同样的操作对于/google/google.txt却不生效：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos mnt]<span class="comment"># vi google.txt</span></span><br><span class="line">this is google</span><br><span class="line"></span><br><span class="line">[root@VM_0_12_centos google]<span class="comment"># vi google.txt</span></span><br><span class="line">(空)</span><br></pre></td></tr></table></figure></p>
<p>这里是因为在使用mount aufs指令的时候，我们没有指定权限，默认最左边的目录拥有读写的权限，后面的目录为只读权限。</p>
<h4 id="Btrfs"><a href="#Btrfs" class="headerlink" title="Btrfs"></a>Btrfs</h4><p>&emsp;&emsp;Btrfs号称下一代写时复制文件系统，目标是取代Linux目前的ext3文件系统，目前已经并入Linux内核中，Btrfs具有以下特质（只列举部分）：</p>
<ul>
<li>扩展性(scalability)  Btrfs将磁盘空间划分为多个chunk，每个chunk可以使用不同的磁盘空间分配策略，这样做可以灵活地分配设备空间，用户在系统中增加新的磁盘之后，可以使用Btrfs的命令将该设备添加到文件系统中。</li>
<li>数据一致性 (data integrity)  Btrfs采用CoW事务技术来保证文件系统的一致性，并且支持checksum，能够快速检测文件是否受损，如果损坏还能尝试修复，这样极大的提高数据的准确性，避免因硬件故障导致Silent corruption的出现。</li>
<li>支持创建快照 (snapshot）和克隆 (clone），可以方便地管理多个物理设备。</li>
</ul>
<h4 id="Device-mapper"><a href="#Device-mapper" class="headerlink" title="Device mapper"></a>Device mapper</h4><p>&emsp;&emsp;Device mapper是Linux2.6内核中提供的一种从逻辑设备到物理设备的映射机制，在该机制下，用户可以很方便的根据自己的需要制定实现存储资源的管理策略，如条带化，镜像，快照等，其中<strong>Thin-Provisioning Snapshot</strong>，这是Docker使用DeviceMapper中最重要的模块。<strong>Thin-Provisioning</strong>（储存资源随需分配）是一项利用虚拟化方法减少物理存储部署的技术，可最大限度提升存储空间利用率，举个例子来说，比如你购买了1TB的云空间容量，然后只存了100GB的内容，实际上分配给你的空间就是100G，并不是实际上的1TB。<strong>Thin-provisioning Snapshot</strong> 结合<strong>Thin-Provisioning</strong>和<strong>Snapshot</strong>两种技术，允许多个虚拟设备同时挂载到一个数据卷以达到数据共享的目的，结合CoW技术，在写操作的时候触发实际的存储分配。</p>
<h4 id="OverlayFS"><a href="#OverlayFS" class="headerlink" title="OverlayFS"></a>OverlayFS</h4><p>&emsp;&emsp;OverlayFS是一种流行的Union FS，类似于AUFS，不过OverlayFS是内核提供的文件系统，和AUFS的多层不同，Overlay只有两层：一个upper文件系统和一个lower文件系统，分别代表Docker的镜像层和容器层。当需要修改一个文件时，使用CoW将文件从只读的lower复制到可写的upper进行修改，结果也保存在upper层，并通过merged的目录公开（挂载点）。在Docker中，底下的只读层就是image，可写层就是Container。结构如下图所示：<br><img src="http://ww1.sinaimg.cn/large/639cfad5gy1g62faram38j216c0aydiq.jpg" alt></p>
<p>Docker为OverlayFS提供两种存储驱动，Overlay和Overlay2。Overlay2是Overlay的更新版本，在4.0以上内核添加了Multiple lower layers in overlayfs的特性，可以支持多个lower layers挂载，现在centos（我的是centos 7.6.1810）中默认使用的就是Overlay2，后面的Docker文件示例中也会以此举例。</p>
<h4 id="ZFS"><a href="#ZFS" class="headerlink" title="ZFS"></a>ZFS</h4><p>&emsp;&emsp;ZFS也是号称下一代文件存储系统，它从根本上改变了文件系统的管理方式。ZFS 完全抛弃了“卷管理”，不再创建虚拟的卷，而是把所有设备集中到一个称之为zpools的存储池中来进行管理。在Docker中，首先从zpool分配一个ZFS文件系统给镜像的基础层，而其他镜像层则是这个ZFS文件系统快照的克隆。快照是只读的，而克隆是可写的，用于存储与上一层的差异。当容器启动时在镜像的最顶层生成一个可写层，容器的读写层都是通过这个顶层的快照创建克隆层而来。如下图所示：<br><img src="http://ww1.sinaimg.cn/large/639cfad5gy1g62g398k2uj20i109nt99.jpg" alt></p>
<h4 id="VFS"><a href="#VFS" class="headerlink" title="VFS"></a>VFS</h4><p>&emsp;&emsp;VFS不是一个联合文件存储系统，每一层都是一个真实的目录，也没有CoW的支持，要创建一个新图层，先前的图层会进行“深层复制”。与其他存储驱动程序相比，这会导致磁盘性能下降和磁盘使用空间更多。但是，它强大、稳定，适用于各种环境，可以用作在测试环境中验证其他存储后端的机制。</p>
<h4 id="Docker文件存储示例"><a href="#Docker文件存储示例" class="headerlink" title="Docker文件存储示例"></a>Docker文件存储示例</h4><p>&emsp;&emsp;上面几乎介绍了Docker所有支持的文件存储驱动，那么Docker真实的镜像、容器的文件存储目录结构是怎样的呢？上面说Docker的镜像是一个分层的结构，其实每一个Docker镜像都是由一个一个可读（read-only）的layer组成的。就像我们上面演示的google.txt示例，修改mount中的google.txt不会影响google文件夹中的google.txt，镜像的每一层layer有了这种能力，那么镜像每一层不仅可以重用，而且修改某个镜像层可以保证不会影响其他镜像。<br>&emsp;&emsp;以Overlay2为例，我们来观察一下Docker中容器和镜像层的文件是如何进行读写的。首先Docker默认的存储目录是/var/lib/docker，先看一下这个目录下有什么：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos docker]# ls</span><br><span class="line">containers  image  network  overlay2  plugins  swarm  tmp  trust  volumes</span><br><span class="line">[root@VM_0_12_centos docker]# tree</span><br><span class="line">.</span><br><span class="line">├── containers</span><br><span class="line">├── image</span><br><span class="line">│   └── overlay2</span><br><span class="line">│       ├── distribution</span><br><span class="line">│       ├── imagedb</span><br><span class="line">│       │   ├── content</span><br><span class="line">│       │   │   └── sha256</span><br><span class="line">│       │   └── metadata</span><br><span class="line">│       │       └── sha256</span><br><span class="line">│       ├── layerdb</span><br><span class="line">│       └── repositories.json</span><br><span class="line">├── network</span><br><span class="line">│   └── files</span><br><span class="line">│       └── local-kv.db</span><br><span class="line">├── overlay2</span><br><span class="line">│   └── l</span><br><span class="line">├── plugins</span><br><span class="line">│   ├── storage</span><br><span class="line">│   │   └── blobs</span><br><span class="line">│   │       └── tmp</span><br><span class="line">│   └── tmp</span><br><span class="line">├── swarm</span><br><span class="line">├── tmp</span><br><span class="line">├── trust</span><br><span class="line">└── volumes</span><br><span class="line">    └── metadata.db</span><br></pre></td></tr></table></figure></p>
<p>这里有很多文件夹，我们只关心image和overlay2。可以看到image中还有一个overlay2文件夹，因为Docker会在/var/lib/docker/image目录下按每个存储驱动的名字创建一个目录。在/var/lib/docker/image/overlay2中分为imagedb和layerdb，这两个文件夹有什么关系？前面说过image是由多个layer组合而成的，也就是说这里layer其实是一个共享的层，可能有多个image会指向某个layer。由于这是一个新装的Docker，所以这里面没有什么镜像或者容器的存储信息。现在我们下载一个镜像，然后看一下整个/var/lib/docker的变化：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos docker]<span class="comment"># docker pull alpine</span></span><br><span class="line"></span><br><span class="line">[root@VM_0_12_centos overlay2]<span class="comment"># docker images</span></span><br><span class="line">REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE</span><br><span class="line">docker.io/alpine    latest              b7b28af77ffe        5 weeks ago         5.58 MB</span><br></pre></td></tr></table></figure></p>
<p>此时/var/lib/docker下的image和overlay2发生了变化:<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos overlay2]<span class="comment"># ls</span></span><br><span class="line">eafa64f9b01bf8a652192eeee666f32aaa57bc7c715cc8ef9a7415bc32c643f8  l</span><br><span class="line"></span><br><span class="line">[root@VM_0_12_centos image]<span class="comment"># tree</span></span><br><span class="line">.</span><br><span class="line">└── overlay2</span><br><span class="line">    ├── distribution</span><br><span class="line">    │   ├── diffid-by-digest</span><br><span class="line">    │   │   └── sha256</span><br><span class="line">    │   │       └── 0503825856099e6adb39c8297af09547f69684b7016b7f3680ed801aa310baaa</span><br><span class="line">    │   └── v2metadata-by-diffid</span><br><span class="line">    │       └── sha256</span><br><span class="line">    │           └── 1bfeebd65323b8ddf5bd6a51cc7097b72788bc982e9ab3280d53d3c613adffa7</span><br><span class="line">    ├── imagedb</span><br><span class="line">    │   ├── content</span><br><span class="line">    │   │   └── sha256</span><br><span class="line">    │   │       └── b7b28af77ffec6054d13378df4fdf02725830086c7444d9c278af25312aa39b9</span><br><span class="line">    │   └── metadata</span><br><span class="line">    │       └── sha256</span><br><span class="line">    ├── layerdb</span><br><span class="line">    │   ├── sha256</span><br><span class="line">    │   │   └── 1bfeebd65323b8ddf5bd6a51cc7097b72788bc982e9ab3280d53d3c613adffa7</span><br><span class="line">    │   │       ├── cache-id</span><br><span class="line">    │   │       ├── diff</span><br><span class="line">    │   │       ├── size</span><br><span class="line">    │   │       └── tar-split.json.gz</span><br><span class="line">    │   └── tmp</span><br><span class="line">    └── repositories.json</span><br></pre></td></tr></table></figure></p>
<p>可以看到/var/lib/docker/image/overlay2/imagedb/content/sha256下新增了一个文件b7b28af77ffec6054d13378df4fdf02725830086c7444d9c278af25312aa39b9，这个文件就是我们下载的alpine的元数据信息，如果有多个镜像，可以根据镜像的IMAGE ID查找，比如上面下载的alpine的IMAGE ID就是b7b28af77ffe，和这个文件的开头是吻合的。打开这个文件，可以看到如下信息：<br><figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"architecture"</span>: <span class="string">"amd64"</span>,</span><br><span class="line">    <span class="attr">"config"</span>: &#123;</span><br><span class="line">        <span class="attr">"Hostname"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"Domainname"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"User"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"AttachStdin"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"AttachStdout"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"AttachStderr"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"Tty"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"OpenStdin"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"StdinOnce"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"Env"</span>: [</span><br><span class="line">            <span class="string">"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"</span></span><br><span class="line">        ],</span><br><span class="line">        <span class="attr">"Cmd"</span>: [</span><br><span class="line">            <span class="string">"/bin/sh"</span></span><br><span class="line">        ],</span><br><span class="line">        <span class="attr">"ArgsEscaped"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="attr">"Image"</span>: <span class="string">"sha256:f248cae16d3e1b44bf474ad89815438f10c395f8e532153e4fcd32cbbb150fb3"</span>,</span><br><span class="line">        <span class="attr">"Volumes"</span>: <span class="literal">null</span>,</span><br><span class="line">        <span class="attr">"WorkingDir"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"Entrypoint"</span>: <span class="literal">null</span>,</span><br><span class="line">        <span class="attr">"OnBuild"</span>: <span class="literal">null</span>,</span><br><span class="line">        <span class="attr">"Labels"</span>: <span class="literal">null</span></span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="attr">"container"</span>: <span class="string">"a0625bb53d38b712d9fe7e307c53a5b1f2528189d694a29ba37b7a27bee20029"</span>,</span><br><span class="line">    <span class="attr">"container_config"</span>: &#123;</span><br><span class="line">        <span class="attr">"Hostname"</span>: <span class="string">"a0625bb53d38"</span>,</span><br><span class="line">        <span class="attr">"Domainname"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"User"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"AttachStdin"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"AttachStdout"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"AttachStderr"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"Tty"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"OpenStdin"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"StdinOnce"</span>: <span class="literal">false</span>,</span><br><span class="line">        <span class="attr">"Env"</span>: [</span><br><span class="line">            <span class="string">"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"</span></span><br><span class="line">        ],</span><br><span class="line">        <span class="attr">"Cmd"</span>: [</span><br><span class="line">            <span class="string">"/bin/sh"</span>,</span><br><span class="line">            <span class="string">"-c"</span>,</span><br><span class="line">            <span class="string">"#(nop) "</span>,</span><br><span class="line">            <span class="string">"CMD [\"/bin/sh\"]"</span></span><br><span class="line">        ],</span><br><span class="line">        <span class="attr">"ArgsEscaped"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="attr">"Image"</span>: <span class="string">"sha256:f248cae16d3e1b44bf474ad89815438f10c395f8e532153e4fcd32cbbb150fb3"</span>,</span><br><span class="line">        <span class="attr">"Volumes"</span>: <span class="literal">null</span>,</span><br><span class="line">        <span class="attr">"WorkingDir"</span>: <span class="string">""</span>,</span><br><span class="line">        <span class="attr">"Entrypoint"</span>: <span class="literal">null</span>,</span><br><span class="line">        <span class="attr">"OnBuild"</span>: <span class="literal">null</span>,</span><br><span class="line">        <span class="attr">"Labels"</span>: &#123;&#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="attr">"created"</span>: <span class="string">"2019-07-11T22:20:52.375286404Z"</span>,</span><br><span class="line">    <span class="attr">"docker_version"</span>: <span class="string">"18.06.1-ce"</span>,</span><br><span class="line">    <span class="attr">"history"</span>: [</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"created"</span>: <span class="string">"2019-07-11T22:20:52.139709355Z"</span>,</span><br><span class="line">            <span class="attr">"created_by"</span>: <span class="string">"/bin/sh -c #(nop) ADD file:0eb5ea35741d23fe39cbac245b3a5d84856ed6384f4ff07d496369ee6d960bad in / "</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"created"</span>: <span class="string">"2019-07-11T22:20:52.375286404Z"</span>,</span><br><span class="line">            <span class="attr">"created_by"</span>: <span class="string">"/bin/sh -c #(nop)  CMD [\"/bin/sh\"]"</span>,</span><br><span class="line">            <span class="attr">"empty_layer"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;</span><br><span class="line">    ],</span><br><span class="line">    <span class="attr">"os"</span>: <span class="string">"linux"</span>,</span><br><span class="line">    <span class="attr">"rootfs"</span>: &#123;</span><br><span class="line">        <span class="attr">"type"</span>: <span class="string">"layers"</span>,</span><br><span class="line">        <span class="attr">"diff_ids"</span>: [</span><br><span class="line">            <span class="string">"sha256:1bfeebd65323b8ddf5bd6a51cc7097b72788bc982e9ab3280d53d3c613adffa7"</span></span><br><span class="line">        ]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>可以在rootfs中找到他所引用的layers，并从layers寻找到一个对应的cache-id，此cache-id即为/var/lib/docker/overlay2目录下的文件夹名称，这个就是原始的镜像数据。现在启动alpine，看一下overlay2目录发生了什么变化：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos docker]<span class="comment"># docker run -it alpine</span></span><br><span class="line">// 下面在另外一个控制台打开</span><br><span class="line">[root@VM_0_12_centos overlay2]<span class="comment"># ls</span></span><br><span class="line">703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619       eafa64f9b01bf8a652192eeee666f32aaa57bc7c715cc8ef9a7415bc32c643f8</span><br><span class="line">703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619-init  l</span><br></pre></td></tr></table></figure></p>
<p>其中l是用于存放缩写链接的目录，对应overlay2下的diff目录，这样做是为了挂载命令不会超出长度：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos overlay2]<span class="comment"># ls -l l</span></span><br><span class="line">总用量 12</span><br><span class="line">lrwxrwxrwx 1 root root 77 8月  17 18:28 GYE5P73ALK5GW3IJW3UGN6JKAV -&gt; ../703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619-init/diff</span><br><span class="line">lrwxrwxrwx 1 root root 72 8月  17 18:28 OELGSI3B6E6E6SCN4P7GC7FKWG -&gt; ../703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619/diff</span><br><span class="line">lrwxrwxrwx 1 root root 72 8月  17 16:41 RSEIGX7ORKSD36ZAIEJR77DC3Z -&gt; ../eafa64f9b01bf8a652192eeee666f32aaa57bc7c715cc8ef9a7415bc32c643f8/diff</span><br></pre></td></tr></table></figure></p>
<p>打开另外一个控制台查看overlay2的挂载情况：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos overlay2]<span class="comment"># mount | grep overlay2</span></span><br><span class="line">/dev/vda1 on /var/lib/docker/overlay2 <span class="built_in">type</span> ext3 (rw,noatime)</span><br><span class="line">overlay on /var/lib/docker/overlay2/703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619/merged <span class="built_in">type</span> overlay (rw,relatime,lowerdir=/var/lib/docker/overlay2/l/GYE5P73ALK5GW3IJW3UGN6JKAV:/var/lib/docker/overlay2/l/RSEIGX7ORKSD36ZAIEJR77DC3Z,upperdir=/var/lib/docker/overlay2/703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619/diff,workdir=/var/lib/docker/overlay2/703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619/work)</span><br></pre></td></tr></table></figure></p>
<p>从上面可以看出，overlay2将lowerdir、upperdir、workdir联合挂载，形成最终的merged挂载点，其中”lower1:lower2”这种格式表示不同的lower层目录，workdir用于文件系统挂载后，存放临时和间接文件的工作基目录（work base dir）。接下来，我们进入这个容器新建一个文件夹看一下：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos ~]# docker exec -it 1cd3d6cda02d /bin/sh</span><br><span class="line">/ #  mkdir test2019</span><br></pre></td></tr></table></figure></p>
<p>然后我们就能在/var/lib/docker/overlay2/703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619/diff目录下看到test2019这个文件夹，这个目录由上面可知，实际上是挂载的upperdir，再进入上面显示挂载的lowerdir（/var/lib/docker/overlay2/eafa64f9b01bf8a652192eeee666f32aaa57bc7c715cc8ef9a7415bc32c643f8/diff）中查看，显示是没有这个test2019的。现在，我们可以使用如下指令提交这个修改过的容器：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker commit 1cd3d6cda02d</span><br></pre></td></tr></table></figure></p>
<p>这个命令可以将当前容器的可写层，转换出一个只读层，可以查看/var/lib/docker/overlay2目录下发生了什么变化：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos overlay2]<span class="comment"># ls</span></span><br><span class="line">5209761c5ba129b5c59070d459f2c1dd9fac8e6fc73ccadc045a07c9b2746e8f  703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619-init  l</span><br><span class="line">703c8240b31ba86d3ab699f0884fe1e60ebcfbcb1728bfd29bc90c77ee57c619  eafa64f9b01bf8a652192eeee666f32aaa57bc7c715cc8ef9a7415bc32c643f8</span><br></pre></td></tr></table></figure></p>
<p>出现了一个新的文件夹5209761c5ba129b5c59070d459f2c1dd9fac8e6fc73ccadc045a07c9b2746e8f，进入这个文件夹查看：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos 5209761c5ba129b5c59070d459f2c1dd9fac8e6fc73ccadc045a07c9b2746e8f]<span class="comment"># tree</span></span><br><span class="line">.</span><br><span class="line">├── diff</span><br><span class="line">│   ├── root</span><br><span class="line">│   ├── run</span><br><span class="line">│   │   └── secrets</span><br><span class="line">│   ├── <span class="built_in">test</span></span><br><span class="line">│   └── test2019</span><br><span class="line">├── link</span><br><span class="line">├── lower</span><br><span class="line">├── merged</span><br><span class="line">└── work</span><br></pre></td></tr></table></figure></p>
<p>我们之前写入的test2019就在这里了。重新回过头来再看下，镜像的元数据层/var/lib/docker/image/overlay2/imagedb/content/sha256也会多一个元数据文件，这里只展示这个文件的rootfs部分：<br><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">"rootfs": &#123;</span><br><span class="line">        "type": "layers",</span><br><span class="line">        "diff_ids": [</span><br><span class="line">            "sha256:1bfeebd65323b8ddf5bd6a51cc7097b72788bc982e9ab3280d53d3c613adffa7",</span><br><span class="line">            <span class="string">"sha256:581634caf678f384ba0692b8010213139fd4a0a48785577191b2be2e4fd731ed"</span></span><br><span class="line">        ]</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure></p>
<p>&emsp;&emsp;后面的就不继续往下探究了，上面这个例子，是从Docker的/var/lib/docker目录重点讲解overlay2驱动的文件系统结构，进一步阐述了overlay2读写层挂载的详情，从而提升了对整个Docker镜像、容器的存储结构的了解。</p>
<h4 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h4><blockquote>
<p><a href="https://docs.docker.com/storage/storagedriver/" target="_blank" rel="noopener">《docker docs》</a><br><a href="https://c.isme.pub/2019/03/09/docker-storage-driver/" target="_blank" rel="noopener">《docker基础-存储驱动》</a><br><a href="https://blog.csdn.net/luckyapple1028/article/details/78075358" target="_blank" rel="noopener">《深入理解overlayfs（二）：使用与原理分析》</a></p>
</blockquote>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Docker/" rel="tag"># Docker</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/07/29/Go语言学习笔记/" rel="next" title="Go语言学习笔记">
                <i class="fa fa-chevron-left"></i> Go语言学习笔记
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/07/07/Dubbo之旅（一）Hello-Dubbo/" rel="prev" title="Dubbo之旅（一）Hello,Dubbo">
                Dubbo之旅（一）Hello,Dubbo <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">matrix</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">47</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">18</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#概述"><span class="nav-number">1.</span> <span class="nav-text">概述</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#AUFS"><span class="nav-number">2.</span> <span class="nav-text">AUFS</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#AUFS示例"><span class="nav-number">2.1.</span> <span class="nav-text">AUFS示例</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Btrfs"><span class="nav-number">3.</span> <span class="nav-text">Btrfs</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Device-mapper"><span class="nav-number">4.</span> <span class="nav-text">Device mapper</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#OverlayFS"><span class="nav-number">5.</span> <span class="nav-text">OverlayFS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ZFS"><span class="nav-number">6.</span> <span class="nav-text">ZFS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#VFS"><span class="nav-number">7.</span> <span class="nav-text">VFS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Docker文件存储示例"><span class="nav-number">8.</span> <span class="nav-text">Docker文件存储示例</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Reference"><span class="nav-number">9.</span> <span class="nav-text">Reference</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">matrix</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>
<div class=BbeiAn-info">
  浙ICP备 -
  <a href="http://www.beian.miit.gov.cn">18040498号</a>
  </a>
</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  

    
      <script id="dsq-count-scr" src="https://luyun.disqus.com/count.js" async></script>
    

    
      <script type="text/javascript">
        var disqus_config = function () {
          this.page.url = 'http://yoursite.com/2019/08/18/拥抱Docker（五）基础原理之存储驱动/';
          this.page.identifier = '2019/08/18/拥抱Docker（五）基础原理之存储驱动/';
          this.page.title = '拥抱Docker（五）基础原理之存储驱动';
        };
        var d = document, s = d.createElement('script');
        s.src = 'https://luyun.disqus.com/embed.js';
        s.setAttribute('data-timestamp', '' + +new Date());
        (d.head || d.body).appendChild(s);
      </script>
    

  




	





  














  





  

  

  

  
  

  

  

  

</body>
</html>
